WIFI_ATBM6032X_SITE_METHOD = git
WIFI_ATBM6032X_SITE = https://github.com/gtxaspec/atbm-wifi
WIFI_ATBM6032X_SITE_BRANCH = master
WIFI_ATBM6032X_VERSION = 5c4dd2c6febaa924a81551f5ce8d3e71c728cc91

WIFI_ATBM6032X_LICENSE = GPL-2.0

ATBM6032X_MODULE_NAME = "atbm6032x"

WIFI_ATBM6032X_MODULE_MAKE_OPTS = \
	KDIR=$(LINUX_DIR)

define WIFI_ATBM6032X_LINUX_CONFIG_FIXUPS
	$(call KCONFIG_ENABLE_OPT,CONFIG_WLAN)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WIRELESS)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WIRELESS_EXT)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_CORE)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_PROC)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_PRIV)
	$(call KCONFIG_SET_OPT,CONFIG_CFG80211,y)
	$(call KCONFIG_SET_OPT,CONFIG_MAC80211,y)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_MINSTREL)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_MINSTREL_HT)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_DEFAULT_MINSTREL)
	$(call KCONFIG_SET_OPT,CONFIG_MAC80211_RC_DEFAULT,"minstrel_ht")
endef

LINUX_CONFIG_LOCALVERSION = $(shell awk -F "=" '/^CONFIG_LOCALVERSION=/ {print $$2}' $(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))

define WIFI_ATBM6032X_INSTALL_CONFIGS
	$(INSTALL) -m 0755 -d $(TARGET_DIR)/lib/modules/3.10.14$(LINUX_CONFIG_LOCALVERSION)
	touch $(TARGET_DIR)/lib/modules/3.10.14$(LINUX_CONFIG_LOCALVERSION)/modules.builtin.modinfo

	$(INSTALL) -m 0755 -d $(TARGET_DIR)/usr/share/wifi
	$(INSTALL) -m 0644 -t $(TARGET_DIR)/usr/share/wifi \
		$(WIFI_ATBM_WIFI_PKGDIR)/files/*.txt

	$(INSTALL) -D -m 0644 $(@D)/firmware/firmware_lite_usb.bin \
		$(TARGET_DIR)/lib/firmware/$(call qstrip,$(ATBM6032X_MODULE_NAME))_fw.bin
endef

WIFI_ATBM6032X_POST_INSTALL_TARGET_HOOKS += WIFI_ATBM6032X_INSTALL_CONFIGS

define WIFI_ATBM6032X_COPY_CONFIG
	$(INSTALL) -D -m 0644 $(@D)/configs/atbm6032x.config \
		$(@D)/.config
endef

WIFI_ATBM6032X_PRE_CONFIGURE_HOOKS += WIFI_ATBM6032X_COPY_CONFIG

$(eval $(kernel-module))
$(eval $(generic-package))
